<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>设置</a>
        <a>商户管理</a>
        <a>
          <cite>编辑商户</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div style="padding:15px;">
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>商户名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="mch_name" value="{$mch.mch_name}"  lay-verify="required" autocomplete="off" placeholder="请输入商户名称" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【注册商户所属主体】</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>商户号</label>
                <div class="layui-input-inline">
                    <input type="text" name="mch_number" value="{$mch.mch_number}"  lay-verify="required" autocomplete="off" placeholder="请输入商户号" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【商户入驻平台编号】</div>
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>媒体名称</label>
                <div class="layui-input-inline">
                    <select name="mp_id" lay-search="" lay-verify="required">
                        <option value="">请选媒体</option>
                        {volist name="mp" id="v"}
                        <option value="{$v.id}" {if $mch.mp_id == $v.id}selected{/if}>{$v.mp_name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">必选【商户对应的小程序】</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>校区名称</label>
                <div class="layui-input-inline">
                    <select name="campus_id" lay-search="" lay-verify="required">
                        <option value="">请选校区</option>
                        {volist name="campus" id="v"}
                        <option value="{$v.id}" {if $mch.campus_id == $v.id}selected{/if}>{$v.campus_name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">必选【商户所属校区名称】</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>APPID</label>
                <div class="layui-input-inline">
                    <input type="text" name="mch_appid" value="{$mch.mch_appid}" lay-verify="required" autocomplete="off" placeholder="请输入平台APPID" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【随行付填写机构ID】</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>SECRET</label>
                <div class="layui-input-inline">
                    <input type="text" name="mch_secret" value="{$mch.mch_secret}"  lay-verify="required" autocomplete="off" placeholder="请输入平台SECRET" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【平台SECRET】</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>支付类型</label>
                <div class="layui-input-inline">
                    <select name="pay_type" lay-search="" lay-verify="required">
                        <option value="">请选支付方式</option>
                        {volist name="data[20]" id="v"}
                        <option value="{$v.id}"{if $mch.pay_type == $v.id}selected{/if}>{$v.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">必选【支付平台支付类型】</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">子商户号</label>
                <div class="layui-input-inline">
                    <input type="text" name="sub_mch_number" value="{$mch.sub_mch_number}" autocomplete="off" placeholder="请输入子商户号" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">非必填【服务商下子商户】</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>APPID</label>
                <div class="layui-input-inline">
                    <input type="text" name="sub_appid" value="{$mch.sub_appid}" lay-verify="required" autocomplete="off" placeholder="请输入子商户APPID" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【子商户SUB_APPID】</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span style="color: red;">*</span>SECRET</label>
                <div class="layui-input-inline">
                    <input type="text" name="sub_secret" value="{$mch.sub_secret}" lay-verify="required" autocomplete="off" placeholder="请输入子商户SECRET" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">必填【子商户SUB_SECRET】</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red;">*</span>商户KEY</label>
            <div class="layui-input-block">
                <input type="text" name="mch_key" value="{$mch.mch_key}" lay-verify="required" autocomplete="off" placeholder="请输入商户KEY" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">必填【随行付可任意填写】</div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value="{$mch.id}">
                <input class="layui-btn" lay-submit lay-filter="form" value="立即提交" readonly>
                <a href="{:url('Merchant/lists')}" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['element', 'jquery','form','layer'], function(){
        let $ = layui.jquery
                ,element = layui.element
                ,layer = layui.layer
                ,form = layui.form;
        //监听提交
        form.on('submit(form)', function (data) {
            let field = data.field;
            let isLoad;
            $.ajax({
                url: '{:url("Merchant/edit")}',
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.code === 1) {
                        setTimeout(function () {
                            location.href = result.url;
                        }, 2000);
                    }
                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });
            return false;
        });
    });
</script>